package com.example.itces.utils;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class MD5utils {


    public static String MD5(String username,String password){
//选择加密方式
        String hashAlgorithName = "MD5";
        //加密次数
        int hashIterations = 1024;
        //加“盐”，防止用户使用相同密码时所获的加密后的密码一样
        ByteSource credentialsSalt = ByteSource.Util.bytes(username);
        //获得加密后的的密码
        SimpleHash simpleHash = new SimpleHash(hashAlgorithName, password, credentialsSalt, hashIterations);

        return simpleHash.toString();
    }
}
